﻿<Window x:Class="wpf_test.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:wpf_test"
        Title="MainWindow" Height="350" Width="525">

    <Window.Resources>
        <local:SprintWorkItemTemplateSelector x:Key="myDataTemplateSelector"/>

        <DataTemplate x:Key="IterationTemplate" >
            <Grid TextBlock.FontFamily="Corbel" TextBlock.FontSize="10" >
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="8*" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>

                <Rectangle Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2" Stroke="Black" StrokeThickness="1" RadiusX="6" RadiusY="6" Margin="1">
                    <Rectangle.Fill>
                        <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                            <GradientStop Color="White" Offset="0.0" />
                            <GradientStop Color="#eeeeee" Offset="0.5" />
                            <GradientStop Color="#cccccc" Offset="1.0" />
                        </LinearGradientBrush>
                    </Rectangle.Fill>
                </Rectangle>

                <TextBlock Grid.Column="0" Grid.Row="0" TextWrapping="NoWrap"  FontSize="24" FontWeight="800" Padding="4" Text="{Binding Title}" />
                <StackPanel Grid.Column="1" Grid.Row="0" HorizontalAlignment="Right" VerticalAlignment="Center" Orientation="Vertical">
                    <TextBlock TextWrapping="NoWrap" Text="{Binding TotalPointsText}" />
                    <TextBlock TextWrapping="NoWrap" Text="{Binding TotalHoursText}" />
                    <TextBlock TextWrapping="NoWrap" Text="{Binding TotalRemainText}" />
                </StackPanel>
            </Grid>
        </DataTemplate>
        
        <DataTemplate x:Key="WorkItemTaskTemplate">
            <Grid TextBlock.FontFamily="Corbel" TextBlock.FontSize="10">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="60" />
                </Grid.ColumnDefinitions>

                <Rectangle Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="3" Grid.RowSpan="3" Stroke="Black" StrokeThickness="1" RadiusX="6" RadiusY="6" Margin="1">
                    <Rectangle.Fill>
                        <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                            <GradientStop Color="White" Offset="0.0" />
                            <GradientStop Color="#eeeeff" Offset="0.5" />
                            <GradientStop Color="#ccccff" Offset="1.0" />
                        </LinearGradientBrush>
                    </Rectangle.Fill>
                </Rectangle>

                <TextBlock Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2" TextWrapping="NoWrap" FontSize="18" FontWeight="800" Padding="4" Text="{Binding Title}"/>
                <TextBlock Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="2" TextWrapping="NoWrap" FontWeight="800" Padding="4" Text="{Binding DescriptionText}"/>
                <TextBlock Grid.Column="0" Grid.Row="2" FontFamily="Corbel" TextWrapping="NoWrap" FontWeight="800" Padding="4" Text="{Binding State}"/>
                <StackPanel Orientation="Horizontal" Grid.Column="1" Grid.Row="2" >
                    <TextBlock TextWrapping="NoWrap" Padding="4" Text="{Binding HoursText}"/>
                    <TextBlock TextWrapping="NoWrap" Padding="4" Text="/"/>
                    <TextBlock TextWrapping="NoWrap" Padding="4" Text="{Binding RemainText}"/>
                </StackPanel>

                <Image Grid.Column="2" Grid.Row="0" Grid.RowSpan="3" Source="c:\downloads\unknown-user-icon.png" Width="60" Margin="4"></Image>
            </Grid>
        </DataTemplate>
    
        <DataTemplate x:Key="WorkItemUserStoryTemplate">
            <Grid TextBlock.FontFamily="Corbel" TextBlock.FontSize="10">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="60" />
                </Grid.ColumnDefinitions>

                <Rectangle Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="3" Grid.RowSpan="3" Stroke="Black" StrokeThickness="1" RadiusX="6" RadiusY="6" Margin="1">
                    <Rectangle.Fill>
                        <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                            <GradientStop Color="White" Offset="0.0" />
                            <GradientStop Color="#eeeecc" Offset="0.5" />
                            <GradientStop Color="#ccccaa" Offset="1.0" />
                        </LinearGradientBrush>
                    </Rectangle.Fill>
                </Rectangle>

                <TextBlock Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2" TextWrapping="NoWrap" FontSize="18" FontWeight="800" Padding="4" Text="{Binding Title}"/>
                <TextBlock Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="2" TextWrapping="NoWrap" Padding="4" Text="{Binding DescriptionText}"/>
                <TextBlock Grid.Column="0" Grid.Row="2" TextWrapping="NoWrap" Padding="4" Text="{Binding State}"/>
                <StackPanel Orientation="Horizontal" Grid.Column="1" Grid.Row="2" >
                    <TextBlock TextWrapping="NoWrap"  Padding="4" Text="{Binding PointsText}"/>
                </StackPanel>

                <Image Grid.Column="2" Grid.Row="0" Grid.RowSpan="3" Source="c:\downloads\unknown-user-icon.png" Width="60" Margin="4"></Image>
            </Grid>
        </DataTemplate>
    </Window.Resources>
    
    <Grid >
        <ListBox Name="_Listbox" VerticalAlignment="Top" ItemsSource="{Binding Path=.}"  ItemTemplateSelector="{StaticResource myDataTemplateSelector}" 
                 HorizontalContentAlignment="Stretch"
                 ScrollViewer.IsDeferredScrollingEnabled="False"
                 ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                 ScrollViewer.VerticalScrollBarVisibility="Visible" >
            <!--<ListBox.ItemTemplateSelector>
            </ListBox.ItemTemplateSelector>-->
        </ListBox>
    </Grid>

</Window>
